package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2019/3/4 11:41
 * @description
 */
public class Code219 {
    public static void main(String[] args) {
        System.out.println(new Code219().containsNearbyDuplicate(new int[] {1, 2, 3, 1, 2, 3}, 3));
    }

    public boolean containsNearbyDuplicate(int[] nums, int k) {
        for (int i = 0; i < nums.length; i++) {
            for (int j = i + 1; j < nums.length; j++) {
                if (nums[i] == nums[j]) {
                    if (j - i <= k) {
                        return true;
                    }
                    break;
                }
            }
        }
        return false;
    }
}
